class Solution {
public:
    int findMin(vector<int>& nums) {
        int low = 0, high = nums.size() - 1;
        while(low < high){
            int mid = (low + high) / 2;
            if(nums[low] < nums[high])return nums[low];
            else if(nums[low] == nums[high]){
                if(nums[mid] < nums[low])high = mid;
                else if(nums[mid] > nums[low]) low = mid + 1;
                else{
                    low++;
                    high--;
                    continue;
                }
            }
            else{
                if(nums[mid] >= nums[low])low = mid + 1;
                else high = mid;
            }
        }
        return min(nums[low], nums[high]);
    }
};

//2021.4.9 
